﻿@{
    Layout = "~/Views/Shared/_FormWhite.cshtml";
}

<div class="wrapper animated fadeInRight">
    <form id="form" class="form-horizontal m">
        <div class="form-group">
            <label class="col-sm-2 control-label ">表名<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="tableName" col="TableName" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">数据类型<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="dataType" col="DataType" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">小数位<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="decimal" col="Decimal" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">允许空值<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="allowNull" col="AllowNull" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">描述2<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="disctription2" col="Disctription2" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">外键关系<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="foreignKey" col="ForeignKey" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">外键对应的字段<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="foreignKeyTableField" col="ForeignKeyTableField" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">数据行等级<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="dataRowLevel" col="DataRowLevel" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">字段名<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="fieldName" col="FieldName" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">数据长度<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="dataLenth" col="DataLenth" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">关键字<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="isKey" col="IsKey" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">描述1<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="disctription1" col="Disctription1" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">描述3<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="disctription3" col="Disctription3" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">外键关系表<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="foreignKeyTable" col="ForeignKeyTable" type="text" class="form-control" />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label ">选择类型<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="selectionType" col="SelectionType" type="text" class="form-control" />
            </div>
            <label class="col-sm-2 control-label ">备注信息<font class="red"> *</font></label>
            <div class="col-sm-4">
                <input id="memo" col="Memo" type="text" class="form-control" />
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    var id = ys.request("id");
    $(function () {
        getForm();

        $('#form').validate({
            rules: {
                tableName: { required: true }
            }
        });
    });

    function getForm() {
        if (id > 0) {
            ys.ajax({
                url: '@Url.Content("~/SystemManage/TableFieldsDisctription/GetFormJson")' + '?id=' + id,
                type: 'get',
                success: function (obj) {
                    if (obj.Tag == 1) {
                        $('#form').setWebControls(obj.Data);
                    }
                }
            });
        }
        else {
            var defaultData = {};
            $('#form').setWebControls(defaultData);
        }
    }

    function saveForm(index) {
        if ($('#form').validate().form()) {
            var postData = $('#form').getWebControls({ Id: id });
            ys.ajax({
                url: '@Url.Content("~/SystemManage/TableFieldsDisctription/SaveFormJson")',
                type: 'post',
                data: postData,
                success: function (obj) {
                    if (obj.Tag == 1) {
                        ys.msgSuccess(obj.Message);
                        parent.searchGrid();
                        parent.layer.close(index);
                    }
                    else {
                        ys.msgError(obj.Message);
                    }
                }
            });
        }
    }
</script>

